//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    loadModal: false,
    loading: false,
    isUserLogin: true,
  },

  onLoad: function () {
    // 获取组件对象
    this.verifycode = this.selectComponent("#verifycode");
  },
  onShow: function () {
    this.setData({
      isUserLogin: wx.getStorageSync('isUserLogin') || false
    })
  },
  loadModal() {
    this.setData({
      loadModal: true
    })
    setTimeout(() => {
      this.setData({
        loadModal: false
      })
    }, 2000)
  },
  start() {
    // 弹出组件
    var _this = this;
    wx.showLoading({
      title: '加载中',
    })
    setTimeout(() => {
      _this.verifycode.showView({
        phone: "13800000000",
        inputSuccess: function (phoneCode) {
          //调用组件关闭方法
          _this.verifycode.closeView();
          //设置数据
          console.log('phoneCode', phoneCode)
          _this.setData({
            code: phoneCode
          });
          wx.showLoading({
            title: '加载中',
          })
          setTimeout(() => {
            wx.hideLoading()
            wx.showToast({
              title: `${phoneCode}`,
            })
          }, 1000)
        }
      });
    }, 800)
  },
  handleTap(event){
    this.setData({
      isUserLogin: true
    },() =>{
      wx.showToast({
        title: '登录成功父级页面处理逻辑',
        icon: 'none'
      })
    })
 
    console.log(event.detail.payload)
  }
})
